<%--
  Created by IntelliJ IDEA.
  User: hct
  Date: 2024/6/6
  Time: 11:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>创建存储空间</title>
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
</head>
<body>
<h1>创建储存空间</h1>
<form method="post" action="#">
    <div>
        <label for="bucketName">存储空间名称</label>
        <input type="text" id="bucketName" name="bucketName" placeholder="请输入存储空间名称" required maxlength="63">
        <br>

        <label>存储类型:</label>
        <input type="radio" name="type" id="standard" value="标准存储" checked>标准存储
        <input type="radio" name="type" id="lowAccess" value="低频访问存储">低频访问存储
        <input type="radio" name="type" id="archive" value="归档存储">归档存储
        <br>

        <label>读写权限:</label>
        <input type="radio" name="permission" id="private" value="Pri" checked>私有（Pri）
        <input type="radio" name="permission" id="publicR" value="R">公共读（R）
        <input type="radio" name="permission" id="publicRW" value="RW">公共读写（RW）
        <br>

        <input type="button" value="确定" id="Sure">
        <input type="button" value="取消" id="Cancel">
    </div>
</form>
</body>
</html>
<script>
    function verifyName() {
    let bucketName = $('#bucketName').val();
    $.ajax({
        url: "${pageContext.request.contextPath}/Oss.action",
        type: 'get',
        data: {opr: 'ossListName', bucketName},
        dataType: 'json',
        success: function (data) {
            if (data == null) {
                let opr = "add";
                let bucketName = $('#bucketName').val().trim()
                if (bucketName.length === 0) {
                    alert("请填写储存空间名称！")
                    return;
                }
            }
        }
    })

    $('#Sure').click(function () {
        verifyName();
    })

    $('#Cancel').click(function () {
        window.location.href = "show.jsp";
    })
</script>
